import Vue from 'vue'
/**
 * @author Jim
 * @description 价格处理过滤器
 */
Vue.filter('priceFilter',(val) => {
  if(val === 0){
    return 0.00
  }
  if(!val) return
  val = parseFloat(val)
  if(Number.isInteger(val)){
    return val
  }else {
    return val.toFixed(2)
  }
})
Vue.filter('timeFilter',(val) => {
  if(!val) return
  if(val.indexOf(':') < 0) return val
  let arr = val.split(':')
  let hours = arr[0]
  let minutes = arr[1]
  let seconds = arr[2]
  if(hours.length < 2){
    hours = `0${hours}`
  }
  if(minutes.length < 2){
    minutes = `0${minutes}`
  }
  if(seconds.length < 2){
    seconds = `0${seconds}`
  }
  return hours+':'+minutes+':'+seconds
})